<?php defined('RUN_KATANA') or die('Restricted access'); ?>
<?php echo $commander->getListCommandsPanel('sa-a-d', ''); ?>
<div class="menu_list">
	<table style="clear:both;" id="menulist" class="item_list" cellspacing="0" cellpadding="0" border="0">
		<thead class="fields">
	        <tr>
	            <th class="first center">&nbsp;&nbsp;Id&nbsp;&nbsp;</th>
	            <th><?php echo ucfirst($txt->getWord('choose')); ?></th>
                <th>&nbsp;</th>
	            <th>&nbsp;&nbsp;#&nbsp;&nbsp;</th>
	            <th><?php echo ucfirst($txt->getWord('title')); ?></th>
                <!--<th><?php echo ucfirst($txt->getWord('alias')); ?></th>-->
	            <th><?php echo ucfirst($txt->getWord('type')); ?></th>
                <th><?php echo ucfirst($txt->getWord('url')); ?></th>
                <th><?php echo ucfirst($txt->getWord('link_target')); ?></th>
	            <th><?php echo ucfirst($txt->getWord('order')); ?></th>
                <th><?php echo ucfirst($txt->getWord('visible')); ?></th>
	            <th><?php echo ucfirst($txt->getWord('active')); ?></th>
                <th><?php echo ucfirst($txt->getWord('access_level')); ?></th>
	            <th><?php echo ucfirst($txt->getWord('edit')); ?></th>
	            <th class="last"><?php echo ucfirst($txt->getWord('delete')); ?></th>
	        </tr>
	    </thead>
	    <tbody>
	        <tr class="items">
	            <td class="first center"><img 	title="<?php echo ucfirst($txt->getWord('new')); ?>"
                                                class="icon command" 
                                                src="<?php echo SYSICONS_URL; ?>add_16.gif" 
                                                onclick="if(document.getElementById('new_m_item').value != '') { edit_form.submit(); }" /></td>
	            <td><input title="<?php echo ucfirst($txt->getWord('all')); ?>" class="select_all" type="checkbox" name="select_all" value="" /></td>
	            <td>&nbsp;</td>
                <td>&nbsp;</td>
	            <td><input class="small" name="new_m_item" type="text" value="" maxlength="50" id="new_m_item" /></td>
                <!--<td><input class="small" name="new_m_item_alias" type="text" value="" maxlength="50"  disabled="disabled" /></td>-->
	            <td>
	            	<select class="small-s" name="new_m_item_type">
	                    <option value="0" <?php echo getIsSelectedHTML($_POST['item_type'], 0);  ?>><?php echo ucfirst($txt->getWord('page')); ?></option>
	                    <option value="1" <?php echo getIsSelectedHTML($_POST['item_type'], 1);  ?>><?php echo ucfirst($txt->getWord('external_link')); ?></option>
	                    <option value="2" <?php echo getIsSelectedHTML($_POST['item_type'], 2);  ?>><?php echo ucfirst($txt->getWord('component_link')); ?></option>
						<option value="5" <?php echo getIsSelectedHTML($_POST['item_type'], 5);  ?>><?php echo ucfirst($txt->getWord('article')); ?></option>
                        <option value="10" <?php echo getIsSelectedHTML($_POST['item_type'], 10);  ?>>RSS Feed</option>
	                </select>
	            </td>
	            <td colspan="7">&nbsp;</td>
	            <td class="last"></td>
	        </tr>
            <?php 
			if($siteAdmin->Sitemap->CurrentPage->SubItems)
			{
				$components = $siteAdmin->getSiteComponents();
				foreach($siteAdmin->Sitemap->CurrentPage->SubItems as $subitem)
				{
				?>
                <tr class="items">
                	<td class="first center"><?php echo $subitem->getId(); ?><input type="hidden" name="m_id[]" value="<?php echo $subitem->getId(); ?>" /></td>
                    <td><input class="select_list" type="checkbox" name="selected[]" value="<?php echo $subitem->getId(); ?>" /></td>
                    <td><a href="<?php echo SITE_URL; ?>?m=<?php echo $subitem->getId(); ?>" target="_blank"><img class="icon" src="<?php echo SYSICONS_URL; ?>html_16.gif" /></a></td>
                    <td><?php echo ($subitem->MenuOrder+1); ?>.</td>
                    <td><input class="small" name="m_title[]" type="text" value="<?php echo $subitem->getTitle(); ?>" maxlength="50" /></td>
                    <!--<td><input class="small" name="m_alias[]" type="text" value="<?php echo $subitem->getAlias(); ?>" maxlength="50" disabled="disabled" /></td>-->
                    <td>
                        <select class="small-s" name="m_item_link_type[]" onchange="submit();">
                            <option value="0" <?php echo getIsSelectedHTML($subitem->getLinkType(), 0); ?>><?php echo ucfirst($txt->getWord('page')); ?></option>
                            <option value="1" <?php echo getIsSelectedHTML($subitem->getLinkType(), 1); ?>><?php echo ucfirst($txt->getWord('external_link')); ?></option>
                            <option value="2" <?php echo getIsSelectedHTML($subitem->getLinkType(), 2);  ?>><?php echo ucfirst($txt->getWord('component_link')); ?></option>
							<option value="5" <?php echo getIsSelectedHTML($subitem->getLinkType(), 5); ?>><?php echo ucfirst($txt->getWord('article')); ?></option>
                            <option value="10" <?php echo getIsSelectedHTML($subitem->getLinkType(), 10);  ?>>RSS Feed</option>
                        </select>
                    </td>
                    <td>
						<?php if($subitem->getLinkType() == 2): ?>
						<select class="medium" name="m_link_id[]" onchange="submit();">
								<?php
								foreach($components as $component)
								{
									if($subitem->getLinkId() == $component['com_id'])
									{ echo '<option value="'.$component['com_id'].'" selected>'.$component['name_l'].' '.$component['name_r'].'</option>'; }
									else
									{ echo '<option value="'.$component['com_id'].'">'.$component['name_l'].' '.$component['name_r'].'</option>'; }
								}
								?>
						</select>
						<?php endif;?>
                    	<?php if(($subitem->getLinkType() == 1) || ($subitem->getLinkType() == 10)): ?>
                        <input class="medium" name="m_link_url[]" type="text" value="<?php echo $subitem->getLinkUrl(); ?>" />
                        <?php else: ?>
                        <input name="m_link_url[]" type="hidden" value="<?php echo $subitem->getLinkUrl(); ?>" />&nbsp;
                        <?php endif; ?>
						
                    </td>
                    <td>
                        <select class="small-s" name="m_link_target[]" onchange="submit();">
                            <option value="0" <?php echo getIsSelectedHTML($subitem->getLinkTarget(), 0); ?>><?php echo ucfirst($txt->getWord('link_target_self')); ?></option>
                            <option value="1" <?php echo getIsSelectedHTML($subitem->getLinkTarget(), 1); ?>><?php echo ucfirst($txt->getWord('link_target_blank')); ?></option>
                        </select>
                    </td>
                    <td class="center"><!--&nbsp;&nbsp;
                        <select name="m_order[]" class="x-small" onchange="submit();">
                            <?php 
                            for($i=0; $i<count($siteAdmin->Sitemap->CurrentPage->SubItems); $i++)
                            { echo '<option value="'.$i.'" '.getIsSelectedHTML($subitem->MenuOrder, $i).'>'.($i+1).'</option>'; }
                            ?>
                        </select> -->
						<?php echo $commander->getCommandButton('up', $subitem->getId()); ?>
                        <?php echo $commander->getCommandButton('down', $subitem->getId()); ?>
                    </td>
                    <td class="center">
						<?php echo $commander->getVisibleFieldsObject($subitem); ?>
                        <input type="hidden" name="m_visible[]" value="<?php echo $subitem->getVisible(); ?>" />
                    </td>
                    <td class="center">
						<?php echo $commander->getActivationFieldsObject($subitem); ?>
                        <input type="hidden" name="m_active[]" value="<?php echo $subitem->getActive(); ?>" />
                    </td>
                    <td>
                        <select name="m_access[]" class="small" onchange="submit();">
                        <?php 
                        if($ac->getAccessLevels())
                        {
                            foreach($ac->getAccessLevels() as $level)
                            { echo '<option value="'.$level->getId().'" '.getIsSelectedHTML($level->getId(), $subitem->getAccess()).'>'.ucfirst($txt->getWord($level->getTitle())).'</option>'; }
                        }
                        ?>
                        </select>
                    </td>
                    <td class="center">
					<a href="?con=<?php echo $_REQUEST['con']; ?>&m=<?php echo $subitem->getId(); ?>"><img title="<?php echo ucfirst($txt->getWord('edit')); ?>" class="icon command" src="<?php echo SYSICONS_URL; ?>configure_16.gif" onclick="edit_form.submit();"  /></a>
					</td>
                    <td class="last"><input title="<?php echo ucfirst($txt->getWord('delete')); ?>" class="inp_image" type="image" name="delete_m" src="<?php echo SYSICONS_URL; ?>delete_16.gif" value="0" onclick="this.value='<?php echo $subitem->getId(); ?>'; edit_form.submit();" /></td>
            	</tr>
                <?php
				}
			}
			?>
	   </tbody>
	</table>
</div>


